package org.ptkparty.client.view.championships;

import java.util.List;

import org.ptkparty.client.model.ChampionshipProxy;
import org.ptkparty.client.model.UserProxy;
import org.ptkparty.client.ui.ChampionshipStateListBox;
import org.ptkparty.client.ui.CustomValueBoxEditorDecorator;
import org.ptkparty.client.ui.UserSelectionCellListView;

import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.Editor;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.MultiSelectionModel;

public class ChampionshipView extends Composite implements Editor<ChampionshipProxy> {

	private static ChampionshipViewUiBinder uiBinder = GWT.create(ChampionshipViewUiBinder.class);

	interface ChampionshipViewUiBinder extends UiBinder<Widget, ChampionshipView> {
	}

	@UiField
	@Path("name")
	CustomValueBoxEditorDecorator<String> nameTb;

	@UiField(provided = true)
	@Path("users")
	UserSelectionCellListView playerList;

	@UiField(provided = true)
	@Path("state")
	ChampionshipStateListBox state = new ChampionshipStateListBox();

	public ChampionshipView(List<UserProxy> userlist) {
		playerList = new UserSelectionCellListView(new MultiSelectionModel<UserProxy>());

		ListDataProvider<UserProxy> provider = new ListDataProvider<UserProxy>();
		provider.addDataDisplay(playerList);
		playerList.setProvider(provider);
		provider.setList(userlist);

		initWidget(uiBinder.createAndBindUi(this));
	}

}
